package com.ck.proxy;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;

public class MyTest {

    public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
        File file = new File(".");
        InputStream intput = new FileInputStream(file.getCanonicalPath() + "\\ck-proxy\\target\\classes\\com\\ck\\proxy\\Programmer.class");
        byte[] result = new byte[1024];
        int count = intput.read(result);
        MyClassLoader loader = new MyClassLoader();
        Class clazz = loader.defineMyClass(result,0,count);
        System.out.println(clazz.getCanonicalName());

        Object o = clazz.newInstance();
            try {
                clazz.getMethod("code",null).invoke(o,null);
            } catch (InvocationTargetException | NoSuchMethodException e) {
                e.printStackTrace();
            }

    }
}
